package com.jy.modules.cims.component.common.service;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jy.modules.cims.data.common.dao.TCMmImgurlDao;
import com.jy.modules.cims.data.common.dto.TCMmImgurlDTO;
import com.jy.platform.core.common.BaseDTO;


/**
 * @classname: TCMmImgurlService
 * @description: 定义  该表进件和合同共用此表，若是进件场景，则贷款编号字段存储进件信息主件，合同号存储进件编号 实现类
 * @author:  zhiqiang
 */
@Service("com.jy.modules.cims.component.common.service.TCMmImgurlService")
public class TCMmImgurlService implements Serializable {

    private static final long serialVersionUID = 1L;
    
	@Autowired
	private TCMmImgurlDao dao;

	/**
     * @author zhiqiang
     * @description: 分页查询 该表进件和合同共用此表，若是进件场景，则贷款编号字段存储进件信息主件，合同号存储进件编号列表
     * @date 2015-01-07 16:22:50
     * @param searchParams 条件
     * @return
     * @throws
     */ 
	public List<TCMmImgurlDTO> searchTCMmImgurlByPaging(Map<String,Object> searchParams) throws Exception {
		List<TCMmImgurlDTO> dataList =  dao.searchTCMmImgurlByPaging(searchParams);
		return dataList;
	}
	/**
     * @author zhiqiang
     * @description: 按条件查询该表进件和合同共用此表，若是进件场景，则贷款编号字段存储进件信息主件，合同号存储进件编号列表
     * @date 2015-01-07 16:22:50
     * @param searchParams 条件
     * @return
     * @throws
     */
	public List<TCMmImgurlDTO> searchTCMmImgurl(Map<String,Object> searchParams) throws Exception {
	    List<TCMmImgurlDTO> dataList = dao.searchTCMmImgurl(searchParams);
        return dataList;
    }
	/**
     * @author zhiqiang
     * @description: 查询该表进件和合同共用此表，若是进件场景，则贷款编号字段存储进件信息主件，合同号存储进件编号对象
     * @date 2015-01-07 16:22:50
     * @param id
     * @return
     * @throws
     */ 
	public TCMmImgurlDTO queryTCMmImgurlByPrimaryKey(String id) throws Exception {
		
		TCMmImgurlDTO dto = dao.findTCMmImgurlByPrimaryKey(id);
		
		if(dto == null) dto = new TCMmImgurlDTO();
		
		return dto;
		
	}

	/**
     * @title: insertTCMmImgurl
     * @author zhiqiang
     * @description: 新增 该表进件和合同共用此表，若是进件场景，则贷款编号字段存储进件信息主件，合同号存储进件编号对象
     * @date 2015-01-07 16:22:50
     * @param dto
     * @return
     * @throws
     */
	@SuppressWarnings("all")
	public Long insertTCMmImgurl(TCMmImgurlDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		int count = dao.insertTCMmImgurl(paramMap);
		
		TCMmImgurlDTO resultDto = (TCMmImgurlDTO) paramMap.get("dto");
		Long keyId = resultDto.getId();
		return keyId;
	}
	/**
     * @title: updateTCMmImgurl
     * @author zhiqiang
     * @description: 修改 该表进件和合同共用此表，若是进件场景，则贷款编号字段存储进件信息主件，合同号存储进件编号对象
     * @date 2015-01-07 16:22:50
     * @param paramMap
     * @return
     * @throws
     */
	public void updateTCMmImgurl(TCMmImgurlDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmImgurl(paramMap);
	}
	/**
     * @title: deleteTCMmImgurlByPrimaryKey
     * @author zhiqiang
     * @description: 删除 该表进件和合同共用此表，若是进件场景，则贷款编号字段存储进件信息主件，合同号存储进件编号,按主键
     * @date 2015-01-07 16:22:50
     * @param paramMap
     * @throws
     */ 
	public void deleteTCMmImgurlByPrimaryKey(BaseDTO baseDto,String ids) throws Exception {
		if(StringUtils.isEmpty(ids)) throw new Exception("删除失败！传入的参数主键为null");
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", baseDto);
		paramMap.put("ids", ids);
		dao.deleteTCMmImgurlByPrimaryKey(paramMap);
	}

}

